﻿Public Class FrmCouncil
    Private x_council As X_Council
    Private x_council_old As X_Council
    Private _parentForm As SuperForm

    Public Sub New(ByVal xcouncil As X_Council, ByVal parentForm As SuperForm)
        InitializeComponent()

        Me._parentForm = parentForm

        Me.x_council = xcouncil

        Me.x_council_old = Me.x_council

        '' Viet:
        Me.txtMucDich_Type.Items.Add(COUNCIL_TYPE._INVENTORY)
        Me.txtMucDich_Type.Items.Add(COUNCIL_TYPE._DISPOSAL)
        Me.txtMucDich_Type.SelectedIndex = 0
        ini()
    End Sub

    Private Function ini() As Boolean

        Me.dtpThoiGian.Text = Me.x_council_old.getValue(I_Council.ColumnName_ThoiGian)
        Me.txtDiaDiem.Text = Me.x_council_old.getValue(I_Council.ColumnName_DiaDiem)
        Me.txtDienGiai.Text = Me.x_council_old.getValue(I_Council.ColumnName_DienGiai)
        Me.txtMucDich_Type.Text = Me.x_council_old.getValue(I_Council.ColumnName_Type)
        Return True
    End Function


    Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub


    Private Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        ini()
    End Sub


    Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

        Me.x_council.setValue(I_Council.ColumnName_DiaDiem, Me.txtDiaDiem.Text)
        Me.x_council.setValue(I_Council.ColumnName_DienGiai, Me.txtDienGiai.Text)
        Me.x_council.setValue(I_Council.ColumnName_ThoiGian, Me.dtpThoiGian.Text)
        Me.x_council.setValue(I_Council.ColumnName_Type, Me.txtMucDich_Type.Text)
        Me.x_council.save(True)

        Me._parentForm.loadCouncil()
        Me._parentForm.specifyCorrespondingDetail()

        Me.Close()

    End Sub
End Class